package com.dongdongshop.util;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.teaopenapi.models.Config;

public class Sample {
    //无用了，换成了config配置
    public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId,String accessKeySecret) throws Exception{
        Config config = new Config()
                //您的accessKey  Id
                .setAccessKeyId(accessKeyId)
                //accessKey  Secret
                .setAccessKeySecret(accessKeySecret);
                //访问的域名
        config.endpoint = "dysmsapi.aliyuncs.com";
        return new com.aliyun.dysmsapi20170525.Client(config);
    }

    public static void main(String[] args_) throws Exception{
        //创建客户端工具
        Client client = Sample.createClient("LTAI4GCbdwnjCGwQj9Z3tr3N","27ih4pc1W1tqey9X4mmCy1JUotAX7L");
        String str = "1234";
        SendSmsRequest sendSmsRequest = new SendSmsRequest()
                .setPhoneNumbers("15358865165")
                .setSignName("东科创想")
                .setTemplateCode("SMS_162522027")
                .setTemplateParam("{\"sms_code\" : \""+ str +"\"}");
        //复制代码运行请自行打印API的返回值
        client.sendSms(sendSmsRequest);
    }
}
